package com.hs.jpademo1.dao;

import com.hs.jpademo1.entity.Person;
import com.hs.jpademo1.entity.Student;
import org.springframework.beans.BeanUtils;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName PersonDao
 * @Description
 */
@Component
public interface PersonDao extends JpaRepository<Person,Integer>, JpaSpecificationExecutor<Person> {
    /**
     * 根据输入的新明模糊查询
     * @param name
     * @return java.util.List<com.hs.jpademo1.entity.Person>
     */
    List<Person> findByNameLike(String name);

    List<Person> findByAgeBetween(Integer minAge, Integer maxAge);

    List<Person> findByAgeBetweenAndStateEquals(Integer minAge, Integer maxAge,Integer state);

    default Person updatePerson(Person person){
        return save(person);
    }
}
